<?php
class model_admin extends framework_base_model {
	/**
	 * 判断是否登陆
	 */
	public static function islogin(){
		//framework_static_function::write_log(json_encode($_SESSION),'session');
		if(isset($_SESSION['admin']['username']) && !empty($_SESSION['admin']['username'])){
			return true;
		}else{
			return false;
		}
	} 

	public static function get_mysql_version(){
		$sql = "select version() as version";
		$stmt = self::DB()->dbh ->prepare($sql);
		$stmt->execute();
		$version = $stmt->fetch();
		return empty($version['version'])?'':$version['version'];
	}

	//获取一级权限ID
	public static function get_parent_authority_id($str){
		$return = array();
		try{
			$sql = "select DISTINCT parent_id from weixin_authority where authority_id in (select DISTINCT parent_id from weixin_authority where authority_id in ({$str}));";
			$pdo = self::DB()->dbh;
			$st = $pdo->prepare($sql);
			$st->execute();
			$return = $st->fetchAll();
			return $return;
		}catch(Exception $e){
			framework_static_function::write_log($e->getMessage(),'error_sql');
    		return $return;
		}

	}
}
